﻿#include "ui_helpinfodalog.h"
#include "helpinfodalog.h"
#include <QMessageBox>




HelpInfoDialog::HelpInfoDialog(CenteredWidget *parent) :
    QDialog(parent),
    ui(new Ui::HelpInfoDalog)
{
    ui->setupUi(this);

    setWindowFlags (Qt::Window
                    | Qt::CustomizeWindowHint
                    | Qt::WindowTitleHint
                    | Qt::WindowMaximizeButtonHint
                    | Qt::WindowCloseButtonHint
                    | Qt::WindowMinimizeButtonHint);


    setVersion (tr ("SolidROC version %1, documentation version %2")
                .arg (Config::appVersion ())
                .arg (Config::docVersion ()));

    ui->close->setIcon (QIcon::fromTheme ("window-close", QIcon (":/images/window-close.svg")));
    ui->listVersions->setIcon (QIcon::fromTheme ("web-browser", QIcon (":/images/web-browser.svg")));
    ui->aboutQt->setIcon (QIcon (":/images/qt-logo.svg"));

    //m_webView = ui->webView;

    const QUrl& url (Config::docFileUrl ());

    if (!url.isEmpty ()) {
        //m_webView->setUrl (url);
    }
}
//------------------------------
HelpInfoDialog::~HelpInfoDialog()
{
    delete ui;
}
//----------------------------------------
void HelpInfoDialog::changeEvent(QEvent *event)
{
    QDialog::changeEvent (event);
    switch (event->type ())
    {
    case QEvent::LanguageChange:
        ui->retranslateUi (this);
        break;

    default:
        break;
    }
}
//-------------------------------------
void HelpInfoDialog::setPage (int page)
{
    ui->tabWidget->setCurrentIndex (page);
}
//-----------------------------------------------------
void HelpInfoDialog::setVersion (const QString &version)
{
    ui->version->setText (version);
}
//--------------------------------------
void HelpInfoDialog::on_aboutQt_clicked()
{
    QMessageBox::aboutQt (this, tr ("SolidROC est développée avec Qt"));
}
//---------------------------------------------
void HelpInfoDialog::on_listVersions_clicked ()
{
    const QString& url ("http://code.google.com/p/solidroc/downloads/list");
    qDebug () << "je tente d'ouvrir " << url;
    qDebug () << QString ("résultat=%1").arg (QDesktopServices::openUrl (QUrl (url)));
}
